package codingforgreat.lchot150;

import java.util.LinkedList;

public class Lc240 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int N = matrix.length;
        int M = matrix[0].length;
        int i = 0,j = M - 1;
        while(i < N && j >= 0){
            if(matrix[i][j] == target){
                return true;
            }
            if(matrix[i][j] < target){
                i++;
            }else{
                j--;
            }
        }
        return false;
    }
}
